<template>
  <view class="application-record">
    <!-- <view class="search">
      <input
        class="form-control"
        type="text"
        placeholder="搜索"
        v-model="searchValue"
        @confirm="confirm"
      />
      <icon type="search" size="14" class="search-icon" />
    </view> -->
	<view class="" style="height: 30rpx;"></view>
    <apply-item
      :applyItem="item"
      :current="current"
      v-for="item of applicationList"
      :key="item.id"
    ></apply-item>
    <view v-if="!applicationList.length" class="empty">暂无数据</view>
  </view>
</template>

<script>
import ApplyItem from "./components/ApplyItem";
import config from '@/config/config';
export default {
  name: "apply-list",
  components: {
    ApplyItem,
  },
  data() {
    return {
      current: 1,
      searchValue: "",
      applicationList: [],
      pageNum: 1,
      pageSize: 10,
      obj: "",
    };
  },
  onLoad(option) {
	  config.verifyToken()
    this.obj = option;
    this.getMyApplyList();
  },
  onPullDownRefresh() {
    this.refresh();
  },
  onReachBottom() {
    this.getMyApplyList();
  },
  methods: {
    // 搜索
    confirm(e) {
      this.searchValue = e.detail.value;
      this.refresh();
    },
    // 刷新
    refresh() {
      this.pageNum = 1;
      this.applicationList = [];
      this.getMyApplyList();
    },
    // 获取申请记录列表
    getMyApplyList() {
      let params = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
      };
      if (this.obj.approvalStatus == 0) {
        params.approvalStatus = this.obj.approvalStatus;
      }
      if (this.searchValue) {
        params.personnel = this.searchValue;
      }
	  uni.showLoading({
	    title: "加载中",
	  });
      this.$http
        .get(this.obj.approvalStatus==0?"/system/car/myUnfinishlist":"/flowable/task/myProcess", params)
        .then((res) => {
          let list = this.obj.approvalStatus==0?res.data.rows:res.data.records;
          this.applicationList = this.applicationList.concat(list);
          this.pageNum++;
          uni.stopPullDownRefresh();
		  uni.hideLoading()
        })
        .catch((errorData) => {
          console.log(errorData);
          uni.stopPullDownRefresh();
		  uni.hideLoading()
        });
    },
  },
};
</script>

<style lang="scss">
.application-record {
  .search {
    padding: 10px;
    position: relative;
  }

  .search-icon {
    position: absolute;
    left: 20px;
    top: 18px;
  }

  .form-control {
    height: 30px;
    border-radius: 10px;
    padding: 0 10px 0 30px;
    background-color: #fff;
    font-size: 24upx;
  }
}
.empty {
  margin-top: 200px;
  text-align: center;
}
</style>
